package com.play2gether;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

/**
 * Created by Raul on 16/05/14.
 */
public class navbarActivity extends ActionBarActivity implements View.OnClickListener{

    private DataBaseManager db;
    //Botones para el navbar
    public Button btFormularioNV;
    public Button btSugerenciaNV;
    public Button btOpcionesNV;

    public navbarActivity(){}

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.navbar);

        //url = "http://mediadomeprojects.com/arkdyanbyte/play2gether/public/pooling";

        //preferencias = getSharedPreferences("sesion",Context.MODE_PRIVATE);
        //id = preferencias.getString("id", "");
        //String sesionActiva = preferencias.getString("activa","");

        db = new DataBaseManager(this);

        //Botones para el navbar
        btFormularioNV = (Button) findViewById(R.id.btFormularioNV);
        btSugerenciaNV = (Button) findViewById(R.id.btSugerenciaNV);
        btOpcionesNV   = (Button) findViewById(R.id.btOpcionesNV);

        //Botones para el navbar
        btFormularioNV.setOnClickListener(this);
        btSugerenciaNV.setOnClickListener(this);
        btOpcionesNV.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent intent;

        switch (v.getId()) {
            case R.id.btFormularioNV:
                final CharSequence[] items1 = {"Formulario1", "Formulario2", "Formulario3", "Formulario4", "Cerrar"};

                AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
                builder1.setTitle("Menu de opciones");
                builder1.setItems(items1, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        Intent intent;

                        dialog.cancel();
/*
                        switch(item){
                            case 0: intent = new Intent(MenuPrincipalActivity.this,formularioActivity.class);
                                startActivity(intent);
                                break;
                            case 1: intent = new Intent(MenuPrincipalActivity.this,formularioActivity.class);
                                startActivity(intent);
                                break;
                            case 2: intent = new Intent(MenuPrincipalActivity.this,formularioActivity.class);
                                startActivity(intent);
                                break;
                            case 3: intent = new Intent(MenuPrincipalActivity.this,formularioActivity.class);
                                startActivity(intent);
                                break;
                            case 4: intent = new Intent(MenuPrincipalActivity.this,formularioActivity.class);
                                startActivity(intent);
                                break;
                        }*/
                    }
                });
                AlertDialog alert1 = builder1.create();
                alert1.requestWindowFeature(Window.FEATURE_NO_TITLE);
                WindowManager.LayoutParams wmlp1 = alert1.getWindow().getAttributes();
                wmlp1.gravity = Gravity.TOP | Gravity.RIGHT;
                wmlp1.x = 0;   //x position
                wmlp1.y = 124;   //y position
                alert1.show();

                break;
            case R.id.btSugerenciaNV:
                break;
            case R.id.btOpcionesNV:

                final CharSequence[] items2 = {"Mi perfil", "Configurar mi play2gether", "Cerrar sesión", "Desvincularme de mi pareja", "Sobre play2gether", "Cerrar"};

                AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
                builder2.setTitle("Menu de opciones");
                builder2.setItems(items2, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {


                        dialog.cancel();
                        /*
                        switch(item){
                            case 0: Intent intent = new Intent(MenuPrincipalActivity.this,PerfilActivity.class);
                                startActivity(intent);
                                break;
                            case 1: break;
                            case 2: //guardarSesion("0");
                                intent = new Intent(MenuPrincipalActivity.this,loginActivity.class);
                                finish();
                                startActivity(intent);
                                break;
                            case 3: break;
                            case 4: break;


                        }
*/

                    }
                });
                AlertDialog alert2 = builder2.create();
                alert2.requestWindowFeature(Window.FEATURE_NO_TITLE);
                WindowManager.LayoutParams wmlp2 = alert2.getWindow().getAttributes();
                wmlp2.gravity = Gravity.TOP | Gravity.RIGHT;
                wmlp2.x = 0;   //x position
                wmlp2.y = 124;   //y position
                alert2.show();
                break;

        }
    }
}
